package org.example.leetcpde;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

public class intToRoman {

    @Nested
    class Solution {
        @Test
        void intToRoman() {
            System.out.println(intToRoman(68));
        }

        int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};

        public String intToRoman(int num) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < values.length; i++) {
                int value = values[i];

                while (num >= value) {
                    num -= value;
                    builder.append(symbols[i]);
                }
            }

            return builder.toString();
        }
    }
}
